<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('货物参数列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>

                            <li>
                                <label>商品名称：</label>
                                <input type="text" name="goodName"/>
                            </li>

                            <li>
                                <label>参数：</label>
                                <input type="text" name="goodParameters"/>
                            </li>

                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:goodparameter:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:goodparameter:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:goodparameter:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:goodparameter:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:goodparameter:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:goodparameter:remove')}]];
        var prefix = ctx + "system/goodparameter";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "货物参数",
                columns: [{
                    checkbox: true
                },
//                {
//                    field: 'goodParameterId',
//                    title: '货物参数表ID',
//                    visible: false
//                },
//                {
//                    field: 'goodsId',
//                    title: '货物表ID'
//                },
                {
                    field: 'attribite3',
                   title: '商品品牌'
                },
                {
                    field: 'goodName',
                    title: '商品名称'
                },
                {
                    field: 'attribite3',
                    title: '商品品牌'
                },
                    {
                        field: 'goodPrice',
                        title: '入围价格'
                    }/*,
                {
                    field: 'goodParameters',
                    title: '参数',
                    formatter: function(value, row, index) {
                        // 图片预览（注意：如存储在本地直接获取数据库路径，如有配置context-path需要使用ctx+路径）
                        // 如：/profile/upload/2019/08/08/3b7a839aced67397bac694d77611ce72.png
                       var o=JSON.parse(value)
                        return o.other;


                    }
                }*/,
                {
                    field: 'goodStatus',
                    title: '商品状态',
                    formatter: function(value, row, index) {
                        // 图片预览（注意：如存储在本地直接获取数据库路径，如有配置context-path需要使用ctx+路径）
                        // 如：/profile/upload/2019/08/08/3b7a839aced67397bac694d77611ce72.png
                        if(value=='0'){
                            return "未审核状态"
                        }else if(value=='1'){
                            return '审核通过'
                        }else if(value=='-1'){
                            return "审核驳回";
                        }


                    }
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    sortable: true
                },
                {
                    field: 'imageUrl',
                    title: '产品图片',
                    formatter: function(value, row, index) {
                        // 图片预览（注意：如存储在本地直接获取数据库路径，如有配置context-path需要使用ctx+路径）
                        // 如：/profile/upload··/2019/08/08/3b7a839aced67397bac694d77611ce72.png
                        var images=JSON.parse(value);
                        var img="";
                        if(images!=""&&images!=null&&images!=undefined){
                            for(var i=0;i<images.length;i++){
                                img+=$.table.imageView(value=images[i],height="800px")
                            }
                        }
                            return img;

                    }
                },
//                {
//                    field: 'withoption',
//                    title: '配选件'
//                },
                {
                    field: 'remarks',
                    title: '备注'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="look(\'' + row.goodParameterId + '\')"><i class="fa fa-edit"></i>查看</a> ');
                        if(row.goodStatus!='1'){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="editstatus(\'' + row.goodParameterId + '\')"><i class="fa fa-edit"></i>商品审核</a> ');
                        }
                        if(row.goodStatus=='0'){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.goodParameterId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.goodParameterId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function editstatus(id){
            $.modal.open("审核货物",prefix+"/editread/"+id,800,600);
        }
        function look(id){
            $.modal.open("查看货物",prefix+"/look/"+id,800,600);
        }

    </script>
</body>
</html>